//
//  PolygonSprite.h
//  CutCut
//
//  Created by Bullet Hermit on 12-11-2.
//  Copyright 2012年 紫竹飞燕. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "cocos2d.h"
#import "Box2D.h"
#import "PRFilledPolygon.h"
#define PTM_RATIO 32
typedef enum
{
    kStateIdle = 0,
    kStateTossed,
}State;
typedef enum
{
    kTypeWatermelon = 0,
    kTypeStrawberry,
    kTypePineapple,
    kTypeGrapes,
    kTypeBanana,
    kTypeBomb         
}Type;
@interface PolygonSprite : PRFilledPolygon {
    b2Body* _body;
    b2Vec2 _centroid;
    BOOL _isOriginal;
    
    BOOL _isSliceEntered;
    BOOL _isSliceExited;
    b2Vec2 _entryPoint;
    b2Vec2 _exitPoint;
    double _sliceEntryTime;
    
    State _state;
    Type _type;
    
    CCParticleSystemQuad* _splurt;
}
@property (nonatomic,assign) b2Body* body;
@property (nonatomic,readwrite) b2Vec2 centroid;
@property (nonatomic,readwrite) BOOL isOriginal;
@property (nonatomic,readwrite) BOOL isSliceEntered;
@property (nonatomic,readwrite) BOOL isSliceExited;
@property (nonatomic,readwrite) b2Vec2 entryPoint;
@property (nonatomic,readwrite) b2Vec2 exitPoint;
@property (nonatomic,readwrite) double sliceEntryTime;
@property (nonatomic,readwrite) State state;
@property (nonatomic,readwrite) Type type;
@property (nonatomic,retain) CCParticleSystemQuad *splurt;
+(id) spriteWithFile:(NSString*)filename body:(b2Body*) body original:(BOOL) isOriginal;
+(id) spriteWithTexture:(CCTexture2D*) texture body:(b2Body*) body original:(BOOL) isOriginal;
+(id) spriteWithWorld:(b2World*) world;
-(id) initWithFile:(NSString*)filename body:(b2Body*) body original:(BOOL) isOriginal;
-(id) initWithTexture:(CCTexture2D*) texture body:(b2Body*) body original:(BOOL) isOriginal;
-(id) initWithWorld:(b2World*) world;
-(void) activeCollisions;
-(void) deactiveCollisions;
-(b2Body*) createBodyForWorld:(b2World *)world position:(b2Vec2)position rotation:(float)rotation vertices:(b2Vec2*)vertices vertexCount:(int32)count density:(float)density friction:(float)friction restitution:(float)restitution;

@end
